package com.cloud.exception;

import com.cloud.common.domain.Result;

/**
 * 回滚异常
 * 定义这个异常,Seata会回滚事务
 *
 * @author yzj
 */
public class RollbackException extends RuntimeException {

    private static final long serialVersionUID = 1L;
    private Integer code;
    private String msg;

    public RollbackException(String message) {
        if (code == null) {
            this.code = Result.WARNING;
        }
        this.msg = message;
    }

    public RollbackException(Integer code, String message) {
        this.code = code;
        this.msg = message;
    }

    public RollbackException(String message, Throwable e) {
        super(message, e);
        this.msg = message;
    }

    @Override
    public String getMessage() {
        return msg;
    }

    public Integer getCode() {
        return code;
    }

}
